import axios from 'axios';
import { API_NEW_VERSION, ALL_SERVICE_API } from '../api';

var qs = require('qs');

// 搜索车辆列表
export const searchVehicleInfo = params => {
  return axios.get(ALL_SERVICE_API + '/vehicle-infos', {params: params});
};

export const searchAllVehicleInfo = params => {
  return axios.get(API_NEW_VERSION + 'vehicle_infos_all', {params: params});
};

// 保存车辆
export const saveVehicleInfo = (params) => {
  return axios.post(ALL_SERVICE_API + '/vehicle-infos', params);
};

// 根据ID获取车辆信息
export const getVehicleInfo = id => {
  return axios.get(ALL_SERVICE_API + '/vehicle-infos/' + id);
};

// 删除车辆
export const delVehicle = id => {
  return axios.delete(ALL_SERVICE_API + '/vehicle-infos/' + id);
};

// 保存车辆指定司机

export const saveDriverInfoAndVehicle = (id, driverInfoIds) => {
  return axios.post(ALL_SERVICE_API + '/vehicle_infos/and/drivers', qs.stringify({
    id: id,
    driverInfoIds: driverInfoIds.join(',')
  }));
};

// 搜索临时车辆列表
export const searchVehicleInfoTemporary = params => {
  return axios.get(API_NEW_VERSION + 'vehicle_infos_temporary', {params: params});
};

// 保存临时车辆信息
export const saveVehicleInfoTemporary = (params) => {
  return axios.post(API_NEW_VERSION + 'vehicle_info_temporary', params);
};
